<?php

//require_once 'PHPUnit/Framework/TestCase.php';
require_once 'PHPUnit/Framework.php';
//require_once('TVB/PWORKS/mvc/action/BaseAction.class.php');
//require_once('TVB/pms/pdes/action/LoginAction.class.php');
require_once('TVB/pms/pdes/common/util/CommonUtils.class.php');


class LoginActionTest extends PHPUnit_Framework_TestCase
{

	protected function setUp()
	{
		$this->url = "http://pdes.tvb.com/pms_list.html?act=add&type=programme&step=1&ut=true";
	}

	protected function tearDown()
	{
	}

	public function testSuccess(){

		$success_data = array(
			"uid"=>"lee",
			"pwd"=>"12345",
		);

		$ret = CommonUtils::curl_test($this->url,$success_data);
		$real_data = json_decode($ret);

		$err_num = count($real_data);

		$this->assertEquals($err_num, 0); 	
	}

	public function testFailed(){
		$success_data = array(
			"uid"=>"",
			"pwd"=>"12345",
		);

		$ret = CommonUtils::curl_test($this->url,$success_data);
		$real_data = json_decode($ret);

		$err_num = count($real_data);
		if ($err_num > 0)
		{
			echo "<pre>";var_export($real_data);
		}

		$this->assertEquals($err_num , 0); 	
	}
     public function testFaild2()
     {
		$success_data = array(
			"uid"=>"",
			"pwd"=>"12345",
		);

		$ret = CommonUtils::curl_test($this->url,$success_data);
		$real_data = json_decode($ret);

		$err_num = count($real_data);
		if ($err_num > 0)
		{
			echo "<pre>";var_export($real_data);
		}

		$this->assertEquals($err_num , 0); 	
     }
}

$suite = new PHPUnit_Framework_TestSuite('LoginActionTest');

// Run the tests
$object = $suite->run();
echo "<pre>";
var_export($object);

 
?>
